home *** CD-ROM | disk | FTP | other *** search
/ MacHome 2001 January / MacHome Magazine Demo Disc January 2001.iso / pc / Software / Networking / Nisus Email.sea / Nisus Email / Email Macros Vol 1 / Email Macros Vol 1
Encoding:
Text File  |  2000-07-01  |  13.4 KB  |  403 lines  |  [SMAC/NISI]

  1. //Clear clipboard 1, for use in loop to accumulate addresses
  2. 1
  3. Clipboard = ""
  4. 0
  5. //Open the Catalog or make sure it si open
  6. Show Catalog
  7. //Start at the beginning
  8. Jump "1"
  9. //Select the first file name
  10. Find Next "^.+" "g-WT"
  11. Loop:
  12. //Copy it to clipboard 9
  13. Copy "9" '&'
  14. //Open the file
  15. Key 
  16. //Begin the Get Addresses part
  17. //Which collects addreses from the
  18. //currently open document and accumulates them
  19. //in current clipboard
  20. //First, remove detailed headers which are now at the end.
  21. Jump "1"
  22. Replace All "^____________________Remaining Header Details____________________:.+" "" "-o-OSAi-wt-Gg"
  23. //Find All Addresses
  24. Find All "[0-9A-z_\-.]+\@[0-9A-z.\-]+\.[A-Za-z][A-Za-z][A-Za-z]-" "gt"
  25. //Put the starts and ends of the selection offsets on a stack
  26. StackOfEdresses->push (StartEnds)
  27. //Clear clipboard 1, for use in loop to accumulate addresses
  28. //Now for the loop where each address is selected
  29. //then copied to current clipboard (1)
  30. //then a return is added to the clipboard
  31. BeginLoop:
  32. //First check if anything left in the stack
  33. if (Not(StackOfEdresses->size)) GoTo FinishDocument
  34. //Pop the last two offsets and use them
  35. //to select the next eddess from the end
  36. SetSelect(StackOfEdresses->pop, StackOfEdresses->pop)
  37. //Append to clipboard 1 and add return
  38. Copy "1"
  39. Copy "1" '\r'
  40. GoTo BeginLoop
  41. FinishDocument:
  42. //End of collecting addresses for the current
  43. //document.
  44. Close 
  45. Key D
  46. Find Next '\C9'
  47. Find Next "^.+" "g-Wt"
  48. If (Not(NumFound)) GoTo Finish
  49. GoTo Loop
  50. Finish:
  51. //Open New File for the Eddresses.
  52. New "Collected Addresses"
  53. Paste "1"
  54. //Begin sorting and removing of duplicates
  55. Select All
  56. lowercase
  57. Sort Paragraphs
  58. Jump "1"
  59. //This expression replaces all repeated paragraphs
  60. //with just one instance. On very long lists this may cause
  61. //an error message “There was an error in searching.”
  62. //If this happens, increase memory allocation to Nisus Writer
  63. //and run the expression again.
  64. Replace All "^\(.+\r\)\1+" "\1" "gt"
  65. //Checks the sequence of letters past the
  66. //last period in the email addresses (or urls) 
  67. //listed in the active window. (each email 
  68. //address must be in its own paragraph or 
  69. //line) Selects all those which have a correct 
  70. //ending, then reverses the selection, thus 
  71. //selecting the illegal email addresses (or //urls) 
  72. //and cuts that, then opens a new file named 
  73. //"Bad Domains" and pastes the list of bad 
  74. //addresses.
  75. Jump "1"
  76. Find All "^[^ @\s]+@.:+:(\.AD|\.AE|\.AF|\.AG|\.AI|\.AL|\.AM|\.AN|\.AO|\.AQ|\.AR|\.AS|\.AT|\.AU|\.AW|\.AZ|\.BA|\.BB|\.BD|\.BE|\.BF|\.BG|\.BH|\.BI|\.BJ|\.BM|\.BN|\.BO|\.BR|\.BS|\.BT|\.BV|\.BW|\.BY|\.BZ|\.CA|\.CC|\.CF|\.CG|\.CH|\.CI|\.CK|\.CL|\.CM|\.CN|\.CO|\.CR|\.CS|\.CU|\.CV|\.CX|\.CY|\.CZ|\.DE|\.DJ|\.DK|\.DM|\.DO|\.DZ|\.EC|\.EE|\.EG|\.EH|\.ER|\.ES|\.ET|\.FI|\.FJ|\.FK|\.FM|\.FO|\.FR|\.FX|\.GA|\.GB|\.GD|\.GE|\.GF|\.GH|\.GI|\.GL|\.GM|\.GN|\.GP|\.GQ|\.GR|\.GS|\.GT|\.GU|\.GW|\.GY|\.HK|\.HM|\.HN|\.HR|\.HT|\.HU|\.ID|\.IE|\.IL|\.IN|\.IO|\.IQ|\.IR|\.IS|\.IT|\.JM|\.JO|\.JP|\.KE|\.KG|\.KH|\.KI|\.KM|\.KN|\.KP|\.KR|\.KW|\.KY|\.KZ|\.LA|\.LB|\.LC|\.LI|\.LK|\.LR|\.LS|\.LT|\.LU|\.LV|\.LY|\.MA|\.MC|\.MD|\.MG|\.MH|\.MK|\.ML|\.MM|\.MN|\.MO|\.MP|\.MQ|\.MR|\.MS|\.MT|\.MU|\.MV|\.MW|\.MX|\.MY|\.MZ|\.NA|\.NC|\.NE|\.NF|\.NG|\.NI|\.NL|\.NO|\.NP|\.NR|\.NT|\.NU|\.NZ|\.OM|\.PA|\.PE|\.PF|\.PG|\.PH|\.PK|\.PL|\.PM|\.PN|\.PR|\.PT|\.PW|\.PY|\.QA|\.RE|\.RO|\.RU|\.RW|\.SA|\.Sb|\.SC|\.SD|\.SE|\.SG|\.SH|\.SI|\.SJ|\.SK|\.SL|\.SM|\.SN|\.SO|\.SR|\.ST|\.SU|\.SV|\.SY|\.SZ|\.TC|\.TD|\.TF|\.TG|\.TH|\.TJ|\.TK|\.TM|\.TN|\.TO|\.TP|\.TR|\.TT|\.TV|\.TW|\.TZ|\.UA|\.UG|\.UK|\.UM|\.US|\.UY|\.UZ|\.VA|\.VC|\.VE|\.VG|\.VI|\.VN|\.VU|\.WF|\.WS|\.YE|\.YT|\.YU|\.ZA|\.ZM|\.ZR|\.ZW|\.COM|\.EDU|\.GOV|\.INT|\.MIL|\.NET|\.ORG|\.ARPA|\.NATO|:d:d-:d-\.:d:d-:d-\.:d:d-:d-\.:d:d-:d-:)\s*:(\r|:e:)" "g"
  77. Select Inverse
  78. If (SelectStart == SelectEnd) GoTo Finish
  79. Cut
  80. New "Bad Domains"
  81. Paste
  82. Exit
  83. Finish:
  84. :1 "No Bad Domains"
  85. //Find All Addresses
  86. Find All "[0-9A-z_\-.]+\@[0-9A-z.\-]+\.[A-Za-z][A-Za-z][A-Za-z]-" "gt"
  87. //Put the starts and ends of the selection offsets on a stack
  88. StackOfEdresses->push (StartEnds)
  89. //Clear clipboard 1, for use in loop to accumulate addresses
  90. 1
  91. Clipboard = ""
  92. //Now for the loop where each address is selected
  93. //then copied to current clipboard (1)
  94. //then a return is added to the clipboard
  95. BeginLoop:
  96. //First check if anything left in the stack
  97. if (Not(StackOfEdresses->size)) GoTo Finish
  98. //Pop the last two offsets and use them to select the last eddess
  99. SetSelect(StackOfEdresses->pop, StackOfEdresses->pop)
  100. Copy 
  101. Copy "" '\r'
  102. GoTo BeginLoop
  103. Finish:
  104. //Open New File for the Eddresses.
  105. New "Collected Addresses"
  106. MacroPaste
  107. 0
  108. Replace In Selection "^" ">" "gt"
  109. //Replace all Returns with a space.
  110. //Returns are ignored in HTML.
  111. Replace All "\r" " " "gt"
  112. //Replace all multiple white space with one space.
  113. Replace All ":b:b+" " " "gt"
  114. //Now replace all break and paragraph tags
  115. //with a Return.
  116. Replace All "<br>|<p>" "\r" "gt"
  117. //Replace a sequence of special symbol codes
  118. //with the corresponding symbol
  119. Replace All """ """" "t"
  120. Replace All "©" "©" "gt"
  121. Replace All "¨" "®" "gt"
  122. //Replace the non-breaking space with a space
  123. Replace All "\ " " " "gt"
  124. //Replace all tags with a return, as each tag
  125. //most likely, though not always, represents
  126. //a change in format.
  127. Replace All "<[^>]+>|\|" "\r" "tg"
  128. //Now clean-up
  129. Replace All ":b*\r:b*\r:b*:(\r:b*:)+" "\r" "gt"
  130. Replace All "^[.,:;\s\t]*" "" "gt"
  131. Replace All "\&\#:d+;" "" "gt"
  132. //This macro first replaces multiple blanks
  133. //with a tab,then removes all blanks at the 
  134. //beginnings of paragraphs. It then removes 
  135. //all returns which are not preceeded by a 
  136. //return or an end of sentence or a colon. //This seems to work well for all emails
  137. Find/Replace "^:b:b+:>[0-9]" "\t" "tgaA"
  138. Find/Replace ":b+$" "" "tgaA"
  139. Find/Replace ":<[^.?!:\r]\r:>[^•\r0-9\t]" " " "tgaA"
  140. Find/Replace ":b:b+" " " "tgaA"
  141. Replace In Selection "^>+" "" "gt"
  142. Replace All "\(^>+.+\r-\)+\r\r" """\1""\r\r" "gt"
  143. Replace All "^\(""\)->" "\1" "gt"
  144. Jump "1"
  145. //Change to clipboard 3 and clear it
  146. 3
  147. Clipboard = ""
  148. //First pick-up any attachment information, if there to clip 3.
  149. Find Next "X\-Attached\:.*\:\([^:]+\)$" "gt"
  150. if (Not(NumFound)) GoTo AttachBypass
  151. Copy "3" ' and attached the file "\1"\r'
  152. AttachBypass:
  153. //First, remove detailed headers which are now at the end.
  154. Jump "1"
  155. Replace All "^____________________Remaining Header Details____________________:.+" "" "-o-OSAi-wt-Gg"
  156. //Then, collect Attribution information on Clipboard 1.
  157. //Switch to Clipboard 1
  158. 1
  159. //Set clipboard to text in case there is no date field
  160. //then then get the date, if it’s there.
  161. Clipboard = "On an unknown date "
  162. Find Next "^Date\:\(.*\)$" "oOSAi©-wt-Gg"
  163. //If no date field by-pass getting it.
  164. if (Not(NumFound)) GoTo NoDateBypass
  165. Copy "" 'On \1 '
  166. //Now remove the date field.
  167. Jump "1"
  168. Find/Replace "^Date\:.+\r" "" "oOSAi©-wt-Gg"
  169. NoDateBypass:
  170. //Get the from field.
  171. Jump "1"
  172. Find Next "^From\:\s*\([^<>@]+\)[^\s\t]+\s*$" "oO-S-Ai-wt-Gg"
  173. if (Not(NumFound)) GoTo NoFromBypass
  174. Copy "" '\1 wrote to '
  175. GoTo FromAdded
  176. NoFromBypass:
  177. Clipboard = Clipboard + "someone wrote to "
  178. FromAdded:
  179. Jump "1"
  180. Find Next "^To\:\s\(.+\)" "oO-S-Ai-wt-Gg"
  181. Copy "" '\1'
  182. //Remove the old “to”
  183. Jump "1"
  184. Find/Replace "^To\:.+\r" "" "oO-S-Ai-wt-Gg"
  185. Jump "1"
  186. //ReplyTo Pickup if it exists
  187. Find Next "^Reply\s-\--\s-to\:\(.+\)" "oO-S-Ai-wt-Gg"
  188. If (Not(NumFound)) GoTo NoReplyField
  189. //Copy Reply-to field to clipboard 2
  190. Copy "2" '\1\r'
  191. //Remove the Reply To field
  192. Jump "1"
  193. Find/Replace "^Reply\s-\--\s-to\:\(.+\)\r" "" "oO-S-Ai-wt-Gg"
  194. 2
  195. Jump "1"
  196. Key To:
  197. MacroPaste
  198. 1
  199. //Remove the From field
  200. Find/Replace "^From\:.+\r" "" "oO-S-Ai-wt-Gg"
  201. GoTo Bypass
  202. NoReplyField:
  203. //Then, switch “from” to “to”.
  204. Find/Replace "^From" "To" "gt"
  205. if (NumFound) GoTo Bypass
  206. :1 "There seems to be no return address."
  207. Bypass:
  208. //Then “cc” removed
  209. Find/Replace "^cc\:.+\r" "" "gt"
  210. Select All
  211. //Make sure all text color is black.
  212. Black
  213. Replace All "^:(To|Subject|bcc|reply\-to:)\:.+\r" "&" "-Og"
  214. //Add the quotes to all beginnings of lines other than those
  215. //marked in red. Put all quoted text in “Ignore Spelling” style.
  216. Replace All "^\(Subject\:\s\)\(\(re\:\s*\s*\)*\(re;*\-\s*\s*\)*\)*" "\1Re-" "gt-O"
  217. Replace All "^.+" ">&" "g-o-Ot"
  218. //Put in the saved attribution information (in green)
  219. Find/Replace "\(\r\r\)" "\1\CC\C3\r" "-o-OSAi-wt-Gg"
  220. Jump "1"
  221. 0
  222. Find Next "^." "gt-o"
  223. Key 
  224. Key 
  225. Key 
  226. Key 
  227. Jump "1"
  228. //Pickup and copy the Cc addresses to Clipboard 4
  229. Find Next "^cc\:\(.+\)" "gt"
  230. Copy "4" '\1'
  231. //Change to clipboard 3 and clear it
  232. 3
  233. Clipboard = ""
  234. //First pick-up any attachment information, if there to clip 3.
  235. Find Next "X\-Attached\:.*\:\([^:]+\)$" "gt"
  236. if (Not(NumFound)) GoTo AttachBypass
  237. Copy "3" ' and attached the file "\1"\r'
  238. AttachBypass:
  239. //First, remove detailed headers which are now at the end.
  240. Jump "1"
  241. Replace All "^____________________Remaining Header Details____________________:.+" "" "-o-OSAi-wt-Gg"
  242. //Then, collect Attribution information on Clipboard 1.
  243. //Switch to Clipboard 1
  244. 1
  245. //Set clipboard to text in case there is no date field
  246. //then then get the date, if it’s there.
  247. Clipboard = "On an unknown date "
  248. Find Next "^Date\:\(.*\)$" "oOSAi©-wt-Gg"
  249. //If no date field by-pass getting it.
  250. if (Not(NumFound)) GoTo NoDateBypass
  251. Copy "" 'On \1 '
  252. //Now remove the date field.
  253. Jump "1"
  254. Find/Replace "^Date\:.+\r" "" "oOSAi©-wt-Gg"
  255. NoDateBypass:
  256. //Get the from field.
  257. Jump "1"
  258. Find Next "^From\:\s*\([^<>@]+\)[^\s\t]+\s*$" "oO-S-Ai-wt-Gg"
  259. if (Not(NumFound)) GoTo NoFromBypass
  260. Copy "" '\1 wrote to '
  261. GoTo FromAdded
  262. NoFromBypass:
  263. Clipboard = Clipboard + "someone wrote to "
  264. FromAdded:
  265. Jump "1"
  266. Find Next "^To\:\s\(.+\)" "oO-S-Ai-wt-Gg"
  267. Copy "" '\1'
  268. //Remove the old “to”
  269. Jump "1"
  270. Find/Replace "^To\:.+\r" "" "oO-S-Ai-wt-Gg"
  271. Jump "1"
  272. //ReplyTo Pickup if it exists
  273. Find Next "^Reply\s-\--\s-to\:\(.+\)" "oO-S-Ai-wt-Gg"
  274. If (Not(NumFound)) GoTo NoReplyField
  275. //Copy Reply-to field to clipboard 2
  276. Copy "2" 'To\: \1'
  277. //Remove the Reply To field
  278. Jump "1"
  279. Find/Replace "^Reply\s-\--\s-to\:\(.+\)\r" "" "oO-S-Ai-wt-Gg"
  280. Jump "1"
  281. Paste "2"
  282. //Change to clipboard 4 for the cc address
  283. If (Clipboard == "") GoTo NoCc
  284. //Add a comma
  285. Key ,
  286. //Paste the cc addresses followed by aa return
  287. Paste "4"
  288. NoCc:
  289. Key 
  290. CcAdded:
  291. 1
  292. //Remove the From field
  293. Find/Replace "^From\:.+\r" "" "oO-S-Ai-wt-Gg"
  294. GoTo Bypass
  295. NoReplyField:
  296. //Then, switch “from” to “to” and add the CC addresss
  297. //in clipboard 4
  298. Find/Replace "^From\:\s*" 'To: \C4, ' "gt"
  299. if (NumFound) GoTo Bypass
  300. :1 "There seems to be no return address."
  301. Bypass:
  302. //Then “cc” removed
  303. Find/Replace "^cc\:.+\r" "" "gt"
  304. Select All
  305. //Make sure all text color is black.
  306. Black
  307. Replace All "^:(To|Subject|bcc|reply\-to:)\:.+\r" "&" "-Og"
  308. //Add the quotes to all beginnings of lines other than those
  309. //marked in red. Put all quoted text in “Ignore Spelling” style.
  310. Replace All "^\(Subject\:\s\)\(\(re\:\s*\s*\)*\(re;*\-\s*\s*\)*\)*" "\1Re-" "gt-O"
  311. Replace All "^.+" ">&" "g-o-Ot"
  312. //Put in the saved attribution information (in green)
  313. Find/Replace "\(\r\r\)" "\1\CC\C3\r" "-o-OSAi-wt-Gg"
  314. Jump "1"
  315. 0
  316. Find Next "^." "gt-o"
  317. Key 
  318. Key 
  319. //Before using this macro, you must change the 
  320. //red text “Your Hard Drive Name” to the actual 
  321. //name of your hard drive.
  322. //=========================
  323. //Change the text in red below to
  324. //the name of your hard drive.
  325. Save As "Your Hard Drive Name:Desktop Folder:Temp"
  326. //Before using you must edit the text in red in this 
  327. //macro to reflect the path to your Dispatch 
  328. //folder.
  329. //===========================
  330. //The “Send On Save” Macro
  331. //When the red text in this macro is adjusted to reflect
  332. //your particular path to the Dispatch folder, inside
  333. //the Nisus Email Program folder, this macro will save
  334. //the current file in the Dispatch folder, causing its
  335. //contents to be sent as a message.
  336. //Convert all variables to text
  337. Select All
  338. Variables to Text
  339. //Replace All smart quotes with dumb ones.
  340. //Remember that in this macro replace expression,
  341. //quotes inside quotes must be doubled
  342. Replace All "“|”" """" "gt"
  343. Replace All "‘|’" "'" "gt"
  344. //Start at beginning
  345. Jump "1"
  346. //If subject field present, pick it up.
  347. Find Next "^Subject\::b*\(....+\)$" "gt"
  348. //If not found continue, else assign file name.
  349. If (NumFound) GoTo NameFile
  350. //Now find the To: field, if it exists, to avoid 
  351. //using it as file name.
  352. Find Next "^To\:" "tg"
  353. //Now find, without wrap, the first longer 
  354. //piece of text and mark as file name.
  355. Find Next "^\(...............:*:b\)......................" "gt-W"
  356. If (NumFound) GoTo NameFile
  357. //If still no name, assign default
  358. //name to Clip 9. 
  359. 9
  360. Clipboard = "Email File w/o name"
  361. 0
  362. //Now we have a name! Save the file.
  363. NameFile:
  364. //If nothing was found, jump over the Copy
  365. //command - can't copy wht's not found.
  366. If (Not(NumFound)) GoTo SaveFile
  367. Copy "9" '\1'
  368. SaveFile:
  369. 9
  370. Clipboard = Clipboard/":"
  371. 0
  372. //Change the text in red to make the path
  373. //to your dispatch folder correct
  374. Save As 'Your Disk Name:Desktop Folder:Nisus Email Folder:Dispatch:\C9'
  375. close
  376.  
  377. //You must customize this macro before you can use it.
  378. //Change the text in red “Path To Folder” to the
  379. //path of the folder where you want the email files saved.
  380. //================================
  381. //This macro  splits into individual files, a single file
  382. //containing  any number of emails,, separated by 
  383. //explicit page breaks.
  384. //Start at the beginning
  385. Jump "1"
  386. loop:
  387. //Find  (and select)  any sequence of characters
  388. //that does not include a page break “\f”
  389. Find Next "\(:[^\f]+\)" "oO-Wt-GgT"
  390. //Use clipboard 1, to preserve the current clipbaord 
  391. //assuming it is not clipbaord 1, being nice to the user
  392. Copy "1"
  393. New
  394. Paste "1"
  395. //Now in this new file find the “to:” field
  396. Find Next "^to\::b*\(....+\)$" "gt"
  397. //Copy address to clipboard 1
  398. Copy "1" '\1'
  399. //Save the new file using the name of the recipient
  400. //which is in clipbaord 1
  401. Save As 'Path To Folder:\C1'
  402. close
  403. goto loop